﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/AgentMaster.Master"
    AutoEventWireup="true" CodeBehind="BuyerList.aspx.cs" Inherits="whatpricemyhouse.agent.BuyerList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">

        function mouseOver1(theObj) {
            theObj.src = "../images/button/send_list-w.png";
        }
        function mouseOut1(theObj) {
            theObj.src = "../images/button/send_list.png";
        }

        function mouseOver2(theObj) {
            theObj.src = "../images/button/print_all_lead-w.png";
        }
        function mouseOut2(theObj) {
            theObj.src = "../images/button/print_all_lead.png";
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:LoginView ID="LoginView2" runat="server">
        <RoleGroups>
            <asp:RoleGroup Roles="agent">
                <ContentTemplate>
                    <div class="buyerListHolder">
                        <asp:Label ID="Label1" runat="server" Text="Agent Area : " CssClass="largeHeaderStep"></asp:Label>
                        <asp:Label ID="Label2" runat="server" Text="Buyer List" CssClass="largeHeaderTitle"></asp:Label>
                        <div class="hrHolder">
                            <hr />
                        </div>
                        <div class="buttonHolder">
                            <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/button/send_list.png" />
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/button/print_all_lead.png" />
                        </div>
                        <div class="hrHolder">
                            <hr />
                        </div>
                        <div class="tableHeader">
                            <div class="tableHeaderItemHolder">
                                <div class="c1">
                                    &nbsp;&nbsp;ID
                                </div>
                                <div class="c2">
                                    Address
                                </div>
                                <div class="c3">
                                    Name
                                </div>
                                <div class="c4">
                                    Date Received
                                </div>
                                <div class="c5">

                                </div>
                            </div>
                        </div>
                        <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" EnableModelValidation="True"
                            DataKeyNames="BRID" OnItemDataBound="ListView1_ItemDataBound">
                            <AlternatingItemTemplate>
                                <div class="itemLine1">
                                    <div class="c1">
                                        &nbsp;<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("BRID","~/agent/EditBuyer.aspx?buyerID={0}") %>'>
                                            <asp:Label ID="PostCodeLabel" runat="server" Text='<%# Eval("postcode") %>' /></asp:HyperLink></div><div class="c2">
                                        <asp:Label ID="PlaceNameLabel" runat="server" Text='<%# Eval("suburb") %>' />
                                    </div>
                                    <div class="c3">
                                        <asp:Label ID="CNameLabel" runat="server" Text='<%# Eval("CName") %>' />
                                    </div>
                                    <div class="c4">
                                         <asp:Label ID="CCreateDateLabel" runat="server" Text='<%# Eval("CCreateDate","{0:dd/MM/yyyy}") %>' />
                                        <div>
                                            Vister: <asp:Label ID="CVsiaLabel" runat="server" Text='<%# Eval("visa") %>' />
                                        </div>
                                    </div>
                                    <div class="c5">
                                        <asp:HyperLink ID="MoveToOld1" runat="server" NavigateUrl='<%# Eval("BRID","~/agent/BuyerList.aspx?old=1&comm=move&buyerid={0}") %>'
                                            ImageUrl="~/images/button/old.png">Move to Old</asp:HyperLink><asp:HyperLink ID="Delete1"
                                                runat="server" NavigateUrl='<%# Eval("BRID", "~/agent/BuyerList.aspx?old=0&comm=delete&buyerid={0}") %>'
                                                ImageUrl="~/images/button/delete.png">Delete</asp:HyperLink></div></div></AlternatingItemTemplate><EditItemTemplate>
                                <span style="background-color: #008A8C; color: #FFFFFF;">PostCode: <asp:TextBox ID="PostCodeTextBox" runat="server" Text='<%# Bind("postcode") %>' />
                                    <br />
                                    PlaceName: <asp:TextBox ID="PlaceNameTextBox" runat="server" Text='<%# Bind("suburb") %>' />
                                    <br />
                                    CName: <asp:TextBox ID="CNameTextBox" runat="server" Text='<%# Bind("CName") %>' />
                                    <br />
                                    <asp:CheckBox ID="isOldCheckBox" runat="server" Checked='<%# Bind("isOld") %>' Text="isOld" />
                                    <br />
                                    CCreateDate: <asp:TextBox ID="CCreateDateTextBox" runat="server" Text='<%# Bind("CCreateDate") %>' />
                                    <br />
                                    BRID: <asp:Label ID="BRIDLabel1" runat="server" Text='<%# Eval("BRID") %>' />
                                    <br />
                                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                                    <br />
                                    <br />
                                </span>
                            </EditItemTemplate>
                            <EmptyDataTemplate>
                                <span>No data was returned.</span></EmptyDataTemplate><InsertItemTemplate>
                                <span style="">PostCode: <asp:TextBox ID="PostCodeTextBox" runat="server" Text='<%# Bind("postcode") %>' />
                                    <br />
                                    PlaceName: <asp:TextBox ID="PlaceNameTextBox" runat="server" Text='<%# Bind("suburb") %>' />
                                    <br />
                                    CName: <asp:TextBox ID="CNameTextBox" runat="server" Text='<%# Bind("CName") %>' />
                                    <br />
                                    <asp:CheckBox ID="isOldCheckBox" runat="server" Checked='<%# Bind("isOld") %>' Text="isOld" />
                                    <br />
                                    CCreateDate: <asp:TextBox ID="CCreateDateTextBox" runat="server" Text='<%# Bind("CCreateDate") %>' />
                                    <br />
                                    BRID: <asp:TextBox ID="BRIDTextBox" runat="server" Text='<%# Bind("BRID") %>' />
                                    <br />
                                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                                    <br />
                                    <br />
                                </span>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <div class="itemLine2">
                                    <div class="c1">
                                        &nbsp;<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("BRID","~/agent/EditBuyer.aspx?buyerID={0}") %>'>
                                            <asp:Label ID="PostCodeLabel" runat="server" Text='<%# Eval("postcode") %>' /></asp:HyperLink></div><div class="c2">
                                        <asp:Label ID="PlaceNameLabel" runat="server" Text='<%# Eval("suburb") %>' />
                                    </div>
                                    <div class="c3">
                                        <asp:Label ID="CNameLabel" runat="server" Text='<%# Eval("CName") %>' />
                                    </div>
                                    <div class="c4">
                                        <asp:Label ID="CCreateDateLabel" runat="server" Text='<%# Eval("CCreateDate","{0:dd/MM/yyyy}") %>' />
                                        <div>
                                            Vister: <asp:Label ID="CVsiaLabel" runat="server" Text='<%# Eval("visa") %>' />
                                        </div>
                                    </div>
                                    <div class="c5">
                                        <asp:HyperLink ID="MoveToOld1" runat="server" NavigateUrl='<%# Eval("BRID","~/agent/BuyerList.aspx?old=1&comm=move&buyerid={0}") %>'
                                            ImageUrl="~/images/button/old.png">Move to Old</asp:HyperLink><asp:HyperLink ID="Delete1"
                                                runat="server" NavigateUrl='<%# Eval("BRID", "~/agent/BuyerList.aspx?old=0&comm=delete&buyerid={0}") %>'
                                                ImageUrl="~/images/button/delete.png">Delete</asp:HyperLink></div></div></ItemTemplate><LayoutTemplate>
                                <div id="itemPlaceholderContainer" runat="server" style="font-family: Verdana, Arial, Helvetica, sans-serif;">
                                    <span runat="server" id="itemPlaceholder" />
                                </div>
                                <div class="tableFooter">
                                </div>
                                <br />
                                <div >
                                    <asp:DataPager ID="DataPager1" runat="server" PageSize="15">
                                        <Fields>
                                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="False" ShowNextPageButton="False"
                                                ShowPreviousPageButton="False" />
                                            <asp:NumericPagerField />
                                            <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="False" ShowNextPageButton="False"
                                                ShowPreviousPageButton="False" />
                                        </Fields>
                                    </asp:DataPager>
                                </div>
                            </LayoutTemplate>
                            <SelectedItemTemplate>
                                <span style="background-color: #008A8C; font-weight: bold; color: #FFFFFF;">PostCode: <asp:Label ID="PostCodeLabel" runat="server" Text='<%# Eval("postcode") %>' />
                                    <br />
                                    PlaceName: <asp:Label ID="PlaceNameLabel" runat="server" Text='<%# Eval("suburb") %>' />
                                    <br />
                                    CName: <asp:Label ID="CNameLabel" runat="server" Text='<%# Eval("CName") %>' />
                                    <br />
                                    <asp:CheckBox ID="isOldCheckBox" runat="server" Checked='<%# Eval("isOld") %>' Enabled="false"
                                        Text="isOld" />
                                    <br />
                                    CCreateDate: <asp:Label ID="CCreateDateLabel" runat="server" Text='<%# Eval("CCreateDate") %>' />
                                    <br />
                                    BRID: <asp:Label ID="BRIDLabel" runat="server" Text='<%# Eval("BRID") %>' />
                                    <br />
                                    <br />
                                </span>
                            </SelectedItemTemplate>
                        </asp:ListView>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:WhatPriceMyHouseConnectionString %>"
                            
                            
                            
                            SelectCommand="SELECT CONVERT (varchar(4), customer_table.CName) AS CName, buy_request_table.isOld, customer_table.CCreateDate, buy_request_table.BRID, suburbs.suburbid, suburbs.suburb, suburbs.area, suburbs.postcode, buy_request_table.visa FROM buy_request_table INNER JOIN customer_table ON buy_request_table.CID = customer_table.CID INNER JOIN suburbs ON buy_request_table.suburbid = suburbs.suburbid WHERE (buy_request_table.isOld = @old) AND (suburbs.area LIKE @area) ORDER BY customer_table.CCreateDate DESC"><SelectParameters>
                                <asp:QueryStringParameter DefaultValue="1" Name="old" QueryStringField="old" />
                                <asp:SessionParameter DefaultValue="auckland" Name="area" SessionField="areaName" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                    </div>
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>
</asp:Content>
